VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Daily check: Validating SARS responses ....."
   ClientHeight    =   7950
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7305
   LinkTopic       =   "Form1"
   ScaleHeight     =   7950
   ScaleWidth      =   7305
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "End"
      Height          =   800
      Left            =   5040
      TabIndex        =   2
      Top             =   6600
      Width           =   2000
   End
   Begin VB.ListBox List1 
      Height          =   6300
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   6975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Enter"
      Height          =   800
      Left            =   120
      TabIndex        =   0
      Top             =   6720
      Width           =   2000
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()

Dim adoConn As ADODB.Connection

Dim rsRequests As ADODB.Recordset
Dim rsResponses As ADODB.Recordset
Dim rsApproved As ADODB.Recordset
Dim rsDeclined As ADODB.Recordset
Dim rsCancelled As ADODB.Recordset
Dim rsResponseFiles As ADODB.Recordset
Dim rsEmailed As ADODB.Recordset
Dim rsDeclinedReasons As ADODB.Recordset
Dim rsReqRes As ADODB.Recordset
Dim rsCaptured As ADODB.Recordset
Dim rsExtract As ADODB.Recordset
Dim rsSent As ADODB.Recordset
Dim rsDemo As ADODB.Recordset
Dim rsCancellNotProc As ADODB.Recordset



Dim adoComm As ADODB.Command
Dim objStrConn As Object
Dim strConnString As String

Dim strsql1 As String
Dim strsql2 As String
Dim strsql3 As String
Dim strsql4 As String
Dim strsql5 As String
Dim strsql6 As String
Dim strsql7 As String
Dim strsql8 As String
Dim strsql9 As String
Dim strsql10 As String
Dim strsql11 As String
Dim strsql12 As String
Dim strsql13 As String
Dim strsql14 As String
Dim strsql15 As String


Dim nRequests As String
Dim nResponses As String
Dim nApproved As String
Dim nDeclined As String
Dim nCancelled As String
Dim nResponseFiles As String
Dim nEmailed As String
Dim strDeclinedReason As String
Dim nReqRes As String
Dim nCaptured As String
Dim nExtract As String
Dim nSent As String
Dim nDemo As String
Dim nCancellNotProc As String

Dim nTotal As String
Dim strErrMsg As String
Dim strTotalErrMsg As String

Dim StrSQL_DailyCheck As String
Dim DailyCheck_ID As Long

Set adoConn = New ADODB.Connection
With adoConn
    .CursorLocation = adUseClient
    .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
    .Open
End With

'**********************DAILY CHECK CRYSTAL REPORT*****************************************
'StrSQL_DailyCheck = "Delete From DAILY_CHECK_REPORT"

'Clear the Daily_Check_Report table
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'StrSQL_DailyCheck = "Insert Into DAILY_CHECK_REPORT(Responses) Values(0)"
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With


'StrSQL_DailyCheck = "Select ID From DAILY_CHECK_REPORT"
'Set rsRequests = New ADODB.Recordset
'With rsRequests
'    .CursorLocation = adUseClient
'    .CursorType = adOpenStatic
'End With
'
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'End With
'
'Set rsRequests = adoComm.Execute
'
'DailyCheck_ID = rsRequests!ID

'******************REQUESTS***************************************************************************
'TOTAL:  how many req were there?
strsql1 = "select count(*) REQUESTS from dir_request where process_status_date >= '" & Date & "'"
strsql1 = strsql1 & " and res_file_name is not null"
strsql1 = strsql1 & " and scod_process_status <> 'CA'"
'--422

Set rsRequests = New ADODB.Recordset
With rsRequests
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql1
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsRequests = adoComm.Execute

nRequests = rsRequests.Fields("REQUESTS").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET Requests=" & nRequests & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'******************RESPONSES************************************************************************
'TOTAL:  how many rep'd to in dir_response?
strsql3 = "select count(*) RESPONSES from dir_response where req_seq_num in("
strsql3 = strsql3 & "select req_seq_num from dir_request where process_status_date >= '" & Date & "'"
strsql3 = strsql3 & " and res_file_name is not null"
strsql3 = strsql3 & " and scod_process_status <> 'CA')"

Set rsResponses = New ADODB.Recordset
With rsResponses
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql3
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsResponses = adoComm.Execute

nResponses = rsResponses.Fields("RESPONSES").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET Responses=" & nResponses & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'*******************APPROVED**********************************************************************
'APPROVED:  how many approved? (request_status = 07)
strsql4 = "select count(*) APPROVED from dir_response where req_seq_num in("
strsql4 = strsql4 & "select req_seq_num from dir_request where process_status_date >= '" & Date & "'"
strsql4 = strsql4 & " and res_file_name is not null"
strsql4 = strsql4 & " and scod_process_status <> 'CA')"
strsql4 = strsql4 & " and request_status = '07'"

Set rsApproved = New ADODB.Recordset
With rsApproved
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql4
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsApproved = adoComm.Execute

nApproved = rsApproved.Fields("APPROVED").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET APPROVED=" & nApproved & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With
'*******************DECLINED**********************************************************************
'DECLINED:  how many declines?
strsql5 = strsql5 & "select count(*) DECLINED from dir_response where req_seq_num in("
strsql5 = strsql5 & "select req_seq_num from dir_request where process_status_date >= '" & Date & "'"
strsql5 = strsql5 & " and res_file_name is not null"
strsql5 = strsql5 & " and scod_process_status <> 'CA')"
strsql5 = strsql5 & " and request_status <> '07'"
strsql5 = strsql5 & " and request_status <> '08'"

Set rsDeclined = New ADODB.Recordset
With rsDeclined
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql5
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsDeclined = adoComm.Execute

nDeclined = rsDeclined.Fields("DECLINED").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET DECLINED=" & nDeclined & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'******************CANCELLED*********************************************************************
'CANCELLED:  how many cancelled? (request_status = 08)
strsql6 = strsql6 & "select count(*) CANCELLED from dir_response where req_seq_num in("
strsql6 = strsql6 & "select req_seq_num from dir_request where process_status_date >= '" & Date & "'"
strsql6 = strsql6 & " and res_file_name is not null"
strsql6 = strsql6 & " and scod_process_status <> 'CA')"
strsql6 = strsql6 & " and cancel_process_status is not null"
strsql6 = strsql6 & " and cancel_status is not null"
'--22

Set rsCancelled = New ADODB.Recordset
With rsCancelled
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql6
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsCancelled = adoComm.Execute

nCancelled = rsCancelled.Fields("CANCELLED").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET CANCELLED=" & nCancelled & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With
'***************RESPONSE FILES*****************************************************************
'all have resp files?
strsql7 = strsql7 & "select * from dir_request where process_status_date >= '" & Date & "'"
strsql7 = strsql7 & " and res_file_name is null"
strsql7 = strsql7 & " and scod_process_status <> 'CA'"
'no records = yes

Set rsResponseFiles = New ADODB.Recordset
With rsResponseFiles
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql7
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsCancelled = adoComm.Execute

nResponseFiles = rsCancelled.RecordCount

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET RESPONSE_FILES=" & nResponseFiles & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With
'**************EMAILED************************************************************************
'--have they all been emailed?
strsql8 = strsql8 & "select count(*) EMAILED from dir_response where req_seq_num in("
strsql8 = strsql8 & "select req_seq_num from dir_request where process_status_date >= '" & Date & "'"
strsql8 = strsql8 & " and res_file_name is not null"
strsql8 = strsql8 & " and scod_process_status <> 'CA')"
strsql8 = strsql8 & " and emailed_yn = 'Y'"

Set rsEmailed = New ADODB.Recordset
With rsEmailed
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql8
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsEmailed = adoComm.Execute

nEmailed = rsEmailed.Fields("EMAILED").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET EMAILED=" & nEmailed & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'***************DECLINED REASONS***************************************************************
'list decline reasons
strsql9 = strsql9 & "select count(decline_reason_text),decline_reason_text from dir_decline_reasons where req_seq_num in("
strsql9 = strsql9 & "select req_seq_num from dir_response where req_seq_num in("
strsql9 = strsql9 & "select req_seq_num from dir_request where process_status_date >= '" & Date & "'"
strsql9 = strsql9 & " and res_file_name is not null"
strsql9 = strsql9 & " and scod_process_status <> 'CA')"
strsql9 = strsql9 & " and request_status <> '07')"
strsql9 = strsql9 & " group by decline_reason_text"
strsql9 = strsql9 & " order by 1 desc,decline_reason_text"

Set rsDeclinedReasons = New ADODB.Recordset
With rsDeclinedReasons
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql9
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsDeclinedReasons = adoComm.Execute

Form1.Show

Dim strDecReasons As String

Do While Not rsDeclinedReasons.EOF
    strDeclinedReason = rsDeclinedReasons.Fields("decline_reason_text").Value
    'strDecReasons = strDecReasons + "- " + Trim(rsDeclinedReasons.Fields("decline_reason_text").Value) + vbCrLf
    rsDeclinedReasons.MoveNext
    strErrMsg = "Declined Reasons: " & strDeclinedReason
    Form1.List1.AddItem strErrMsg
    Form1.List1.Refresh
Loop
'strDecReasons = Left(strDecReasons, Len(strDecReasons) - 1)
Form1.List1.AddItem ""

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET DECLINED_REASONS='" & strDecReasons & "' where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'**********REQUESTS WITHOUT RESPONSES***********************************************************
strsql10 = strsql10 & "select Count(*) ReqRes from dir_request where process_status_date >= '" & Date & "'"
strsql10 = strsql10 & " and res_file_name is not null"
strsql10 = strsql10 & " and scod_process_status <> 'CA'"
strsql10 = strsql10 & " and req_seq_num not in("
strsql10 = strsql10 & " select req_seq_num from dir_response)"

Set rsReqRes = New ADODB.Recordset
With rsReqRes
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql10
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsReqRes = adoComm.Execute
nReqRes = rsReqRes.Fields("ReqRes").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET REQUESTS_WITHOUT_RESPONSES=" & nReqRes & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'*********ANYTHING CAPTURED BEFORE TODAY AND NOT EXTRACTED (EXCEPT ONES THAT WERE CANCELLED)*******
strsql11 = strsql11 & "SELECT Count(*) Captured_not_Extracted FROM DIR_REQUEST"
strsql11 = strsql11 & " WHERE CREATED_DATE <= '" & Date & "'"
strsql11 = strsql11 & " AND SCOD_PROCESS_STATUS ='CA'"
strsql11 = strsql11 & " and req_seq_num in"
strsql11 = strsql11 & " (select req_seq_num from dir_response where"
strsql11 = strsql11 & " cancel_status is null)"

Set rsCaptured = New ADODB.Recordset
With rsCaptured
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql11
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsCaptured = adoComm.Execute
nCaptured = rsCaptured.Fields("Captured_not_Extracted").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET ANYTHING_CAPTURED_BEFORE_TODAY_AND_NOT_EXTRACTED=" & nCaptured & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With
'*******ANYTHING EXTRACTED BEFORE TODAY AND NOT sent (EXCEPT ONES THAT WERE CANCELLED)*************
strsql12 = strsql12 & "SELECT Count(*) Extracted_not_Sent FROM DIR_REQUEST"
strsql12 = strsql12 & " WHERE CREATED_DATE <= '" & Date & "'"
strsql12 = strsql12 & " AND SCOD_PROCESS_STATUS ='EX'"

Set rsExtract = New ADODB.Recordset
With rsExtract
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql12
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsExtract = adoComm.Execute
nExtract = rsExtract.Fields("Extracted_not_Sent").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET ANYTHING_EXTRACTED_BEFORE_TODAY_AND_NOTSENT =" & nExtract & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With
'****ANYTHING THAT SARS HAVE NOT REPLIED TO AFTER HAVING RECEIVED THE FILE************************
strsql13 = strsql13 & "SELECT Count(*) Sent_Not_Received FROM DIR_REQUEST"
strsql13 = strsql13 & " WHERE CREATED_DATE <= '" & Date & "'"
strsql13 = strsql13 & " AND SCOD_PROCESS_STATUS ='FS'"

Set rsSent = New ADODB.Recordset
With rsSent
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql13
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsSent = adoComm.Execute
nSent = rsSent.Fields("Sent_Not_Received").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET ANYTHING_THAT_SARS_HAVE_NOT_REPLIED_TO_AFTER_HAVING_RECEIVED_THE_FILE =" & nSent & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'*******if emp_ids = 0, they won;t be extracted - they should all have been cancelled. Are there any that haven't been cancelled?
strsql14 = strsql14 & "select Count(*) Demo from dir_request"
strsql14 = strsql14 & " where SCOD_PROCESS_STATUS ='CA'"
strsql14 = strsql14 & " AND CREATED_DATE >= '" & Date & "'"
strsql14 = strsql14 & " and emp_id =0"
strsql14 = strsql14 & " and req_seq_num in"
strsql14 = strsql14 & " (select req_seq_num from dir_response  where"
strsql14 = strsql14 & " cancel_process_status is NOT null)"

Set rsDemo = New ADODB.Recordset
With rsDemo
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql14
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsDemo = adoComm.Execute
nDemo = rsDemo.Fields("Demo").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET DEMO_REQUESTS =" & nDemo & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'*****Anything cancelled and not processed?*********************************************************
strsql15 = strsql15 & "select Count(*) Cancelled_not_Processed"
strsql15 = strsql15 & " from dir_response s, dir_request q"
strsql15 = strsql15 & " Where s.req_seq_num = q.req_seq_num"
strsql15 = strsql15 & " and cancel_process_status is not null"
strsql15 = strsql15 & " and cancel_status  is null"

Set rsCancellNotProc = New ADODB.Recordset
With rsCancellNotProc
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
End With

Set adoComm = New ADODB.Command
With adoComm
    .CommandText = strsql15
    .CommandType = adCmdText
    Set .ActiveConnection = adoConn
End With

Set rsCancellNotProc = adoComm.Execute
nCancellNotProc = rsCancellNotProc.Fields("Cancelled_not_Processed").Value

'StrSQL_DailyCheck = "Update DAILY_CHECK_REPORT SET Anything_cancelled_and_not_processed =" & nCancellNotProc & " where ID = " & DailyCheck_ID & ""
'Set adoComm = New ADODB.Command
'With adoComm
'    .CommandText = StrSQL_DailyCheck
'    .CommandType = adCmdText
'    Set .ActiveConnection = adoConn
'    .Execute .CommandText
'End With

'******************ERROR MESSAGES**********************************************************
nTotal = CLng(nApproved) + CLng(nDeclined) + CLng(nCancelled)

If nRequests <> nResponses Then
    strErrMsg = "Fail: Number of requests not equal to number of responses"
Else
    strErrMsg = "Pass: Requests = Responses"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

If nTotal <> nResponses Then
    strErrMsg = "Fail: Number of Responses is not equal to approve, decline, cancel"
Else
    strErrMsg = "Pass: Total Responses = Approved + Declined + Cancelled"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'Do all requests have response files?
If nResponseFiles > 0 Then
    strErrMsg = "Fail: Not all requests have response files"
Else
    strErrMsg = "Pass: All requests have response files"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'Responses not emailed
If nResponses <> nEmailed Then
    strErrMsg = "Fail: Not all responses have been emailed"
Else
    strErrMsg = "Pass: All responses have been emailed"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'REQUESTS WITHOUT RESPONSES
If nReqRes <> 0 Then
    strErrMsg = "Fail: Not all requests have responses"
Else
    strErrMsg = "Pass: All requests have responses"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'ANYTHING CAPTURED BEFORE TODAY AND NOT EXTRACTED (EXCEPT ONES THAT WERE CANCELLED)
If nCaptured <> 0 Then
    strErrMsg = "Fail: Not everything captured, was extracted"
Else
    strErrMsg = "Pass: Everything captured, was extracted"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'ANYTHING EXTRACTED BEFORE TODAY AND NOT sent (EXCEPT ONES THAT WERE CANCELLED)
If nExtract <> 0 Then
    strErrMsg = "Fail: Not everything extracted, was sent to SARS"
Else
    strErrMsg = "Pass: Everything captured, extracted, was sent to SARS"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'ANYTHING THAT SARS HAVE NOT REPLIED TO AFTER HAVING RECEIVED THE FILE
If nSent <> 0 Then
    strErrMsg = "Fail: SARS have not replied to all requests sent to them"
Else
    strErrMsg = "Pass: SARS have replied to all requests sent to them"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'if emp_ids = 0, they won;t be extracted - they should all have been cancelled. Are there any that haven't been cancelled?
If nDemo <> 0 Then
    strErrMsg = "Fail: There were demo requests that have not been cancelled"
Else
    strErrMsg = "Pass: There were no demo requests that have not been cancelled"
End If
Form1.List1.AddItem strErrMsg
Form1.List1.Refresh

'Anything cancelled and not processed
If nCancellNotProc <> 0 Then
    strErrMsg = "Fail: Not all cancelled requests have been processed"
Else
    strErrMsg = "Pass: All cancelled requests have been processed"
End If
End Sub

Private Sub Command2_Click()
Unload Form1
End Sub

